# encoding: utf-8
# @File  : test04.py
# @Author: wu shaofan
# @Date  :  2024/04/18
# @Desc :
import sys
sys.path.append('/var/jenkins_home/python3/lib/python3.8/site-packages')

from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service

import config


# def init_driver():
#     options = Options()
#     options.add_argument('--no-sandbox') # 亲测 Debian 必须加，Ubuntu 随意
#     options.add_argument("--headless")
#     options.add_argument('--disable-gpu')
#     driver = webdriver.Chrome(options=options)
#     driver.get("https://hmshop-test.itheima.net/Home/user/login.html")
#     # 输入框输入“selenium”
#     driver.find_element(By.ID, "username").send_keys("18325530001")
#     print("1111")
#     return driver
#
# init_driver()
#
# print('Success')
# print(init_driver().title)

options = Options()
driver_path = r'/var/jenkins_home/workspace/TPshop_webdemo_pro/chromedriver'
# options.binary_location ="/usr/bin/google-chrome-stable"
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--disable-gpu")

service = Service(driver_path)
driver = webdriver.Chrome(service=service,options=options)
driver.get("https://hmshop-test.itheima.net/Home/user/login.html")
# 输入框输入“selenium”
driver.find_element(By.ID, "username").send_keys("18325530001")
print('Success')
print(driver.title)